#include"util.hpp"
#include"data.hpp"
#include"server.hpp"

//文件测试
void FileTest()
{
    aod::FileUtil("./www").CreateDirectory();
    aod::FileUtil("./www/index.html").SetContent("<html></html>");
    std::string body;
    aod::FileUtil("./www/index.html").GetContent(&body);
    std::cout<<body<<endl;
    std::cout<<aod::FileUtil("./www/index.html").Size()<<endl;
}
//json序列化测试
void JsonTest()
{
    const char* name = "小明";
    int age = 19;
    float score[]={77.5,88,99.5};

    Json::Value val;//定一个对象val,让Json进行序列化，结果放到val中
    val["姓名"]=name;
    val["年龄"]=age;
    val["成绩"].append(score[0]);
    val["成绩"].append(score[1]);
    val["成绩"].append(score[2]);
    std::string body;
    aod::JsonUtil::Serialize(val,&body);
    std::cout << body << std::endl;

    Json::Value vall;
    aod::JsonUtil::UnSerialize(body,&vall);
    cout<<vall["姓名"].asString()<<endl;
    cout<<vall["年龄"].asString()<<endl;
    int sz = vall["成绩"].size();
    for(int i=0;i<sz;i++)
    {
        cout<<val["成绩"][i]<<endl;
    }

}
//数据管理测试
void DataTest()
{
    aod::TableVideo tb_video;
    Json::Value video;
    // video["name"]="西游记后续";
    // video["info"]="这是师徒四人去西天取经的故事，精彩纷呈";
    // video["video"]="/video/four_people.mp4";
    // video["image"]="/image/four_people.jpg";

    //tb_video.Insert(video);

    //tb_video.Update(3,video);

    tb_video.Delete(1);

    // tb_video.SelectAll(&video);
    // string body;
    // aod::JsonUtil::Serialize(video,&body);
    // cout<<body<<endl;

    // tb_video.SelectOne(2,&video);
    // string body;
    // aod::JsonUtil::Serialize(video,&body);
    // cout<<body<<endl;

    // tb_video.SelectLike("金刚",&video);
    // string body;
    // aod::JsonUtil::Serialize(video,&body);
    // cout<<body<<endl;
}
//服务器测试
void ServerTest()
{
    aod::Server server(9090);
    server.RunModule();
}


int main()
{
    //FileTest();
    //JsonTest();
    //DataTest();
    ServerTest();

    return 0;
}